7.18.19
Let’s say that in your group of organisms, you believe that arboreality is associated with lower visual acuity.
Let’s say that in your group of organisms, you believe that arboreality is associated with lower visual acuity.
arboreality <- c(.1, .2, .3, .4, .5, .6, .7, .8) vis_ac <- c(1, .8, .6, .4, .35, .3, .25, .2) plot(arboreality, vis_ac)
What is wrong with what we have done?
arboreality <- c(.1, .2, .3, .4, .5, .6, .7, .8) vis_ac <- c(1, .8, .6, .4, .35, .3, .25, .2) plot(arboreality, vis_ac)
What is wrong with what we have done?
arboreality <- c(.1, .2, .3, .4, .5, .6, .7, .8) vis_ac <- c(1, .8, .6, .4, .35, .3, .25, .2) plot(arboreality, vis_ac)
These are not independent datapoints!
What is the problem with what we’ve done?
Felsenstein Phylogenies and the Comparative Method, 1985
These are not independent datapoints!
Does this mean we simply can’t make these comparsions?
Does this mean we simply can’t make these comparsions?
No! But we must account for the effect of shared heritage.
Based on the random movement of particles in fluid
The idea is that sucessive movements are independent of each other.
Under this model, traits evolve due to a continuous random walk.
The difference (contrast) between the traits possessed by any two tips on the tree will be normally distributed. The mean of the normal will be 0, and the variance will be proportional to the time since common ancestor.
x <- seq(-4, 4, length=100) norms <- dnorm(x, sd = 1) plot(norms)
steps <- 0:50 var <- 0.01 x <- rnorm(n = length(steps) - 1, sd = sqrt(var)) x <- c(0, cumsum(x)) plot(steps, x, type = "line")
## Warning in plot.xy(xy, type, ...): plot type 'line' will be truncated to ## first character
steps <- 0:50
var <- 0.01
n_sims <- 50
sim_mat <- matrix(0, n_sims, length(steps))
for (i in 1:n_sims) {
sim_mat[i, ] <- c(0, cumsum(rnorm(n = length(steps) - 1, sd = sqrt(var))))
}
plot(steps, sim_mat[1, ], type = "line", ylim = c(2, -2)) #when you scale var, you may need to adjust the axis!
## Warning in plot.xy(xy, type, ...): plot type 'line' will be truncated to ## first character
for (i in 1:n_sims) {
lines(steps, sim_mat[i, ])
}
1, 2, 3, 4 are not independent. But the difference between 1 & 2 is independent of the difference between 3 & 4.
Contrasts usually standardized by the variance
library(phytools)
## Loading required package: ape
## Loading required package: maps
tree <- pbtree(n=20) x <- fastBM(tree, sig2 = var, internal = TRUE) x
## t19 t20 t3 t4 t8 ## 0.009223212 -0.070437080 0.124401752 0.088344109 -0.033095364 ## t9 t15 t16 t14 t5 ## 0.117956632 0.111424898 0.149738231 -0.085196710 -0.018092583 ## t6 t1 t12 t17 t18 ## -0.026754123 -0.045039932 -0.181212061 -0.102056619 -0.080236832 ## t13 t2 t7 t10 t11 ## -0.131576134 0.008612053 0.060299042 -0.011597639 -0.049667398 ## 21 22 23 24 25 ## 0.000000000 -0.070681148 -0.032780087 -0.015801379 0.013007371 ## 26 27 28 29 30 ## 0.033602870 0.031192369 0.079338202 0.011105571 0.128412717 ## 31 32 33 34 35 ## 0.131956955 0.037707082 -0.181939928 -0.170017030 -0.144654497 ## 36 37 38 39 ## -0.161316965 0.043964325 0.023988578 0.037729690
phenogram(tree, x)
x <- fastBM(tree, sig2 = var, internal = FALSE) contrasts <- pic(x, tree, scaled=FALSE) contrasts
## 21 22 23 24 25 ## -0.2115216923 -0.0844633705 0.0168993895 -0.1570753861 -0.0960292860 ## 26 27 28 29 30 ## 0.1875301617 -0.1159904336 0.1149664747 -0.1915242398 -0.0139271755 ## 31 32 33 34 35 ## 0.0246090861 -0.0267121758 -0.1799226895 0.0383846328 0.0423184074 ## 36 37 38 39 ## 0.0678331583 -0.1436154218 0.0604193728 -0.0004905934
plot(tree) nodelabels(contrasts)
important_environmental_factor <- seq(from = 1, to = 19, by = 1) plot(contrasts, important_environmental_factor)
Phylogenetic independent contrasts assume we can estimate the value of the trait possessed by an ancestor through Brownian motion
tree_20 <- pbtree(n=20) trait <- fastBM(tree_20) phenogram(tree_20, trait)
anc_states <-anc.ML(tree_20, trait) plotBranchbyTrait(tree_20, trait)
tree_20$tip.states <- trait tree_20$node.labels <- anc_states$ace write.tree(tree_20, file = "annotated.tre")
We’re going back to RevBayes for this.
These methods all assume the tree you tell it is the true tree
These methods all assume the tree you tell it is the true tree
These methods all assume the tree you tell it is the true tree
These methods all assume the tree you tell it is the true tree
These methods all assume the tree you tell it is the true tree
These methods all assume the tree you tell it is the true tree